package com.taxi.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.taxi.constant.AmapConfigConstants;
import com.taxi.dto.DicDistrict;
import com.taxi.mapper.DicDistrictMapper;
import com.taxi.remote.MapDicDistrictClient;
import com.taxi.result.Result;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: aniu
 * @Date: 2023/9/26
 * @ClassName: DistrictService
 * @Description: Write class functionality and purpose here.
 * @Version: 1.0
 */
@Service
public class DistrictService {
    @Autowired
    private MapDicDistrictClient mapDicDistrictClient;
    @Autowired
    private DicDistrictMapper dicDistrictMapper;

    public Result initDicDistrict(String keywords) {
        return mapDicDistrictClient.dicDistrict(keywords);
    }

    public Result getDistrictInfo() {
        //查找 “市” 结尾的
        List<DicDistrict> dicDistricts = dicDistrictMapper.selectList(
                new LambdaQueryWrapper<DicDistrict>().likeLeft(DicDistrict::getAddressName, "市")
        );
        return Result.ok(dicDistricts);
    }

}
